﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PBOffice.Models;
using System.Data;
using System.Data.SqlClient;
namespace PBOffice.DAL
{
    public class StaffExpService
    {
        public List<StaffExp> GetAllByNameAndMonth(string num, string name,int pageIndex,int pageSize)
        {
            List<StaffExp> list = new List<StaffExp>();
            SqlParameter[] spa = {
                                    new SqlParameter("@Name",name),
                                    new SqlParameter("@Month",num),
                                    new SqlParameter("@PageIndex",pageIndex),
                                    new SqlParameter("@PageSize",pageSize)
                                };
            using (SqlDataReader dr = SqlHelp.ExecuteReader(SqlHelp.connectionstring, "proc_NameMonth", spa))
            {
                while (dr.Read())
                {
                    StaffExp exp = new StaffExp();
                    exp.Num = (int)dr["Id"];
                    exp.StfName = dr["StfName"].ToString();
                    list.Add(exp);
                }
            }
            return list;
        }
        public int GetCount(string num,string name)
        {
            SqlParameter [] spa={new SqlParameter("@Name",name),
                                    new SqlParameter("@Month",num)
                                };
            return (int)SqlHelp.ExecuteScalar(SqlHelp.connectionstring, "proc_NameMonthPage", spa);
        }
    }
}
